package Day07;

import java.util.Random;
import java.util.Scanner;

public class VerificationCode2 {
    public static void main(String[] args) {
        Random ran= new Random();//创建一个随机数工具
        Scanner scn=new Scanner(System.in);
        System.out.println(
                "输入验证码长度");
        int cap=scn.nextInt();//验证码长度
        char[] Captcha={//创建一个验证码字符库
                'a','b','c','d','e','f','g','h','i','j','k',
                'l','m','n','o','p','q','r','s','t','u','v',
                'w','x','y','z','A','B','C','D','E','F','G',
                'H','I','J','K','L','M','N','O','P','Q','R',
                'S','T','U','V','W','X','Y','Z','0','1','2',
                '3','4','5','6','7','8','9'};
        String captcha="";//创建一个验证码
        for (int l=0;l<cap;l++){//cap 验证码位数
                captcha+=Captcha[ran.nextInt(Captcha.length)];//将Captcha数组下标范围为Captcha长度的随机数字符赋值给验证码
            }
            System.out.println(captcha);
    }
}
